home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / shared.dxr / 04476_Button Handler -2 -.ls < prev    next >
Encoding:
Text File  |  1996-02-21  |  5.4 KB  |  127 lines

  1. global gOBJECTS, sCURSORSPRITE, gTimerList, theButtonClasses, void
  2.  
  3. on anyButton ObjRef
  4.   if (ObjRef = #describe) or (ObjRef = void) then
  5.     put "this button handler verifies on mouse up inside the hotRect -kam"
  6.     put "It also allows use of a string or symbol "
  7.     put "requires one parameter: 'ObjRef' in symbol format"
  8.     put "use syntax: anyButton #thermdisplay"
  9.     put "this handler not NOT conditional, which pushbutton is"
  10.     exit
  11.   end if
  12.   set obj to getaProp(gOBJECTS, ObjRef)
  13.   if not voidp(getaProp(getaProp(obj, #sound), #down)) then
  14.     stopSound(getaProp(getaProp(obj, #sound), #down))
  15.     playSound(getaProp(getaProp(obj, #sound), #down), #keyframeCast, #NOW)
  16.   end if
  17.   set the castNum of sprite getaProp(obj, #spriteNum) to getaProp(getaProp(obj, #cast), #down)
  18.   updateStage()
  19.   repeat while the stillDown
  20.     if inside(point(the mouseH, the mouseV), getAt(getaProp(obj, #HotRect), 1)) then
  21.       set the castNum of sprite getaProp(obj, #spriteNum) to getaProp(getaProp(obj, #cast), #down)
  22.     else
  23.       set the castNum of sprite getaProp(obj, #spriteNum) to getaProp(getaProp(obj, #cast), #UP)
  24.     end if
  25.     cursorandupdate()
  26.   end repeat
  27.   set myPoint to point(the mouseH, the mouseV)
  28.   if not voidp(getaProp(getaProp(obj, #sound), #UP)) then
  29.     stopSound(getaProp(getaProp(obj, #sound), #UP))
  30.     playSound(getaProp(getaProp(obj, #sound), #UP), #keyframeCast, #NOW)
  31.   end if
  32.   set the castNum of sprite getaProp(obj, #spriteNum) to getaProp(getaProp(obj, #cast), #UP)
  33.   updateStage()
  34.   if inside(myPoint, getAt(getaProp(obj, #HotRect), 1)) then
  35.     do(string(getaProp(getaProp(obj, #action), #UP)))
  36.   end if
  37. end
  38.  
  39. on MultiState ObjRef
  40.   set obj to getaProp(gOBJECTS, ObjRef)
  41.   set nStates to count(getaProp(obj, #AllStates))
  42.   set StateNum to getOne(getaProp(obj, #AllStates), getaProp(obj, #State))
  43.   set StateNum to StateNum + 1
  44.   if StateNum > nStates then
  45.     set StateNum to 1
  46.   end if
  47.   setaProp(obj, #State, getAt(getaProp(obj, #AllStates), StateNum))
  48.   set animlength to count(getaProp(getaProp(obj, #cast), getaProp(obj, #State)))
  49.   repeat with aCast = animlength down to 1
  50.     set the castNum of sprite getaProp(obj, #spriteNum) to getAt(getaProp(getaProp(obj, #cast), getaProp(obj, #State)), aCast)
  51.     cursorandupdate()
  52.   end repeat
  53.   playSound(getaProp(getaProp(obj, #sound), getaProp(obj, #State)), #keyframeCast, #NOW)
  54.   do(getaProp(getaProp(obj, #action), #UP))
  55. end
  56.  
  57. on MultiStateCOND ObjRef
  58.   set obj to getaProp(gOBJECTS, ObjRef)
  59.   if getaProp(getaProp(gOBJECTS, getaProp(obj, #Parent)), #State) = getaProp(obj, #ParentState) then
  60.     set nStates to count(getaProp(obj, #AllStates))
  61.     set StateNum to getOne(getaProp(obj, #AllStates), getaProp(obj, #State))
  62.     set StateNum to StateNum + 1
  63.     if StateNum > nStates then
  64.       set StateNum to 1
  65.     end if
  66.     setaProp(obj, #State, getAt(getaProp(obj, #AllStates), StateNum))
  67.     playSound(getaProp(getaProp(obj, #sound), getaProp(obj, #State)), #keyframeCast)
  68.     set animlength to count(getaProp(getaProp(obj, #cast), getaProp(obj, #State)))
  69.     repeat with aCast = animlength down to 1
  70.       set the castNum of sprite getaProp(obj, #spriteNum) to getAt(getaProp(getaProp(obj, #cast), getaProp(obj, #State)), aCast)
  71.       cursorandupdate()
  72.     end repeat
  73.     do(getaProp(getaProp(obj, #action), #UP))
  74.   end if
  75. end
  76.  
  77. on ButtonDoDn ObjRef
  78.   set obj to getaProp(gOBJECTS, ObjRef)
  79.   if not voidp(getaProp(getaProp(obj, #sound), #down)) then
  80.     stopSound(getaProp(getaProp(obj, #sound), #down))
  81.     playSound(getaProp(getaProp(obj, #sound), #down), #keyframeCast)
  82.   end if
  83.   set the castNum of sprite getaProp(obj, #spriteNum) to getaProp(getaProp(obj, #cast), #down)
  84.   updateStage()
  85.   repeat while the stillDown
  86.     do(getaProp(getaProp(obj, #action), #WhileDown))
  87.     cursorandupdate()
  88.   end repeat
  89.   if not voidp(getaProp(getaProp(obj, #sound), #UP)) then
  90.     stopSound(getaProp(getaProp(obj, #sound), #UP))
  91.     playSound(getaProp(getaProp(obj, #sound), #UP), #keyframeCast)
  92.   end if
  93.   set the castNum of sprite getaProp(obj, #spriteNum) to getaProp(getaProp(obj, #cast), #UP)
  94.   do(getaProp(getaProp(obj, #action), #UP))
  95.   updateStage()
  96. end
  97.  
  98. on pushButton ObjRef
  99.   set obj to getaProp(gOBJECTS, ObjRef)
  100.   if getaProp(getaProp(gOBJECTS, getaProp(obj, #Parent)), #State) = getaProp(obj, #ParentState) then
  101.     if not voidp(getaProp(getaProp(obj, #sound), #down)) then
  102.       stopSound(getaProp(getaProp(obj, #sound), #down))
  103.       playSound(getaProp(getaProp(obj, #sound), #down), #keyframeCast)
  104.     end if
  105.     set the castNum of sprite getaProp(obj, #spriteNum) to getaProp(getaProp(obj, #cast), #down)
  106.     updateStage()
  107.     repeat while the stillDown
  108.       if inside(point(the mouseH, the mouseV), getAt(getaProp(obj, #HotRect), 1)) then
  109.         set the castNum of sprite getaProp(obj, #spriteNum) to getaProp(getaProp(obj, #cast), #down)
  110.       else
  111.         set the castNum of sprite getaProp(obj, #spriteNum) to getaProp(getaProp(obj, #cast), #UP)
  112.       end if
  113.       cursorandupdate()
  114.     end repeat
  115.     set myPoint to point(the mouseH, the mouseV)
  116.     if not voidp(getaProp(getaProp(obj, #sound), #UP)) then
  117.       stopSound(getaProp(getaProp(obj, #sound), #UP))
  118.       playSound(getaProp(getaProp(obj, #sound), #UP), #keyframeCast)
  119.     end if
  120.     set the castNum of sprite getaProp(obj, #spriteNum) to getaProp(getaProp(obj, #cast), #UP)
  121.     updateStage()
  122.     if inside(myPoint, getAt(getaProp(obj, #HotRect), 1)) then
  123.       do(string(getaProp(getaProp(obj, #action), #UP)))
  124.     end if
  125.   end if
  126. end
  127.